import { async } from '@angular/core/testing';
import { Component, OnInit,Injectable } from '@angular/core';
import { VstudentinfoService } from '../../provider/vstudentinfo.service';
import { ModalController } from '@ionic/angular';
import { EventEmitter, Input, Output } from '@angular/core';
import { VstudyInfoComponent } from '../vstudy-info';
import { RouterModule,Routes,Router } from '@angular/router';
@Component({
  selector: 'app-query-model-window',
  templateUrl: 'query-model-window.component.html',
  styleUrls: ['query-model-window.component.scss']
})
@Injectable({
  providedIn: 'root'
})
export class QueryModelWindowComponent  implements OnInit {
  @Output() voted = new EventEmitter<number>();
  vsAttTypelist: any[];


  constructor(public vstudentinfoService: VstudentinfoService, public modalController: ModalController,
    public vstudyInfoComponent:VstudyInfoComponent,public router:Router) {
    
  }

  ngOnInit() { this.getAttTypeList() }

  async getAttTypeList() {

    (await this.vstudentinfoService.getAttTypeList()).subscribe((response: any) => this.vsAttTypelist = response.body.result);
  }

  //async getVStudyList(item)
  //{
  //this.modalController.dismiss();
  //(await this.vstudentinfoService.getVStudyList(item)).subscribe((response: any) => this.vsAttTypelist = response.body.result);
  //}

    async vote(item: number) {
    //當為子組件時觸發
    //this.voted.emit(item);
    //當為模態框時觸發
    this.modalController.dismiss({
      'item':item
    });
  
    //this.router.navigate(['vsinfo',item],{ queryParams: { 'item': item }});
    
    
  }

}
